<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <meta name="viewport" content="width=device-width">
  <title>Convert LaTeX or MathML to Speech</title>
  <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
  <script>
  MathJax = {
    loader: {load: ['input/asciimath', 'input/mml', 'input/tex', 'output/svg', 'sre/sre_browser']},
    tex: {inlineMath: [['$', '$'], ['\\(', '\\)']]},
    startup: {
      ready: function() {
        MathJax.startup.defaultReady();
        // Initialise convert when MathJax/SRE is fully loaded.
        MathJax.startup.promise.then(function () {
           Convert.init();
        });
      }
    }
  };
  </script>
  <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/startup.js"></script>
<style>
body {
  font-family: sans-serif
}
h2 {
  margin: 1.5em 0 1em;
  font-size: 120%;
}
h2:first-child {
  margin-top: .5em;
}
.fullwidth {
  width: 100%;
}
table.fullwidth tr {
  vertical-align: baseline;
}
table.fullwidth td {
  white-space: nowrap;
}
td.fullwidth input {
  width: 100%;
  box-sizing: border-box;
  }
  td.spacing {
  width: 20%
  }
.red {
  color: #880000;
  background-color: #FFEEEE;
}
.green {
  color: #008800;
  background-color: #EEFFEE;
}
#explanation {
  display: inline-block;
  box-sizing: border-box;
  width: 100%;
  min-width: 25em;
  vertical-align: top;
  margin-bottom: 2em;
  line-height: 1.5;
  padding-right: .75em;
}
.converter {
  display: inline-block;
  box-sizing: border-box;
  width: 48%;
  min-width: 25em;
  vertical-align: top;
  background-color: #F0F0F0;
  border: 2px solid #CCC;
  padding: .75em;
}
#input {
  font-family: monospace;
  font-size: 100%;
  padding: .3em;
  width: 100%;
  box-sizing: border-box;
}
#configfile {
  border: 1px solid #AAA;
  padding: 2px;
  font-family: monospace;
  font-size: 100%
}
.speech {
  border: 1px solid #AAA;
  padding: .5em;
  background-color: white;
}
.speech {
  min-height: 8em;
  border: 1px solid #AAA;
  background-color: #F8F8F8;
  padding: .5em .5em .5em 1.5em;
  overflow: auto;
  white-space: pre;
}
#errors code, #explanation code {
  background-color: #EEE;
  display: inline-block;
  padding: 1px 2px;
  border: 1px solid #AAA;
  margin: 1px;
}
#explanation code {
  padding: 0 2px;
}
</style>
<script src="./convert-with-speech.js"></script>
</head>
<body>

<h1>MathJax Speech Converter</h1>

<div id="explanation">
<p>

This tool converts math input expressions given in LaTeX, MathML or AsciiMath to
text output.

</p>
</div>

<div class="converter" id="inputpanel">
  <H2>Input:</h2>
  <textarea rows="15" cols="80" id="input">
  </textarea>
  <table class="fullwidth">
    <tr>
      <td><input type="radio" checked name="format" value="latex"><label for="latex">LaTeX</label></input></td>
      <td><input type="radio" name="format" value="asciimath"><label for="asciimath">AsciiMath</label></input></td>
      <td><input type="radio" name="format" value="mathml"><label for="mathml">MathML</label></input></td>
      <td class="spacing"></td>
      <td><label for="locale">Locale</label>
        <select id="locale" onchange="Convert.updateLocale(value)">
        </select>
      </td>
      <td><label for="locale">Markup</label>
        <select id="markup" onchange="Convert.convertExpression()">
          <option value="none">None</option>
          <option value="punctuation">Punctuation</option>
          <option value="ssml">SSML</option>
          <option value="sable">Sable</option>
        </select>
      </td>
      <td class="fullwidth"></td>
      <td><input type="button" value="Convert"
      onclick="Convert.convertExpression()"/></td>
    </tr>
  </table>

  <h2>Expression:</h2>
  <div id="rendered"></div>

</div>
<div class="converter" id="outputpanel">
  
  <h2>Mathspeak Output:</h2>
  <span><label for="locale">Style</label>
        <select id="style" onchange="Convert.computeMathspeak()">
          <option value="default">Verbose</option>
          <option value="brief">Brief</option>
          <option value="sbrief">Superbrief</option>
        </select>
  </span>
  <pre class="speech" id="mathspeak">
  </pre>

  <h2>Clearspeak Output:</h2>
  <pre class="speech"  id="clearspeak">
  </pre>
  <div>
  <label for="preferences">Preferences:</label>
  <div id="preferences"></div>
  </div>

</div>

</body>
</html>
